import service from "@/utils/index";

// json形式
const options = {
	header: { contentType: "application/json" },
};

/**
 * @method 测试接口
 */
export function testGet(data : any) {
	return service.get("/testGet", data);
}

// 微信授权
// export const doWxAuth = (data: any) => {
//   return service.post("/my/auth", data, options);
// };

// 更新用户昵称
export const updateUserNickName = (data : any) => {
	return service.post("/my/updateUserNickName", data, options);
};

// 获取 顶banner和轮播banner 的接口
export const getOneTemplate = (data : any) => {
	return service.post("/index/page", data, options);
};

//获取全部分类
export const getCategoryList = (data : any) => {
	return service.post("/goods/category", data, options);
};

// 获取 首页商品推荐
export const getGoodsListIndex = (data : any) => {
	return service.post("/index/goodsList", data, options);
};

// 获取 全部商品列表
export const getGoodsList = (data : any) => {
	return service.post("/goods/list", data, options);
};

// 获取 商品详情
export const getGoodsInfo = (data : any) => {
	return service.post("/goods/detail", data, options);
};

// 获取 服务标签
export const getGoodsTag = (data : any) => {
	return service.post("/goods/tag", data, options);
};

// 获取 个人中心各状态的订单数
export const getOrderData = (data : any) => {
	return service.post("/order/data", data, options);
};

// 创建订单（下单）
export const doOrderBuy = (data : any) => {
	return service.post("/order/buy", data, options);
};

export const doAuth = (data : any) => {
	return service.post("/my/auth", data, options);
};

export const getOrderList = (data : any) => {
	return service.post("/order-wx/list", data, options);
};

export const getOrderDetail = (data : any) => {
	return service.post("/order/info", data, options);
};

export const getAgreement = (data : any) => {
	return service.post("/my/agreement", data, options);
};

export const doOrderConfirm = (data : any) => {
	return service.post("/order/confirm", data, options);
};

export const doWxBuy = (data : any) => {
	return service.post("/order-wx/buy", data, options);
};
// 添加售后
export const doAddAftersales = (data : any) => {
	return service.post("/aftersales/add", data, options);
};

// 获取售后信息
export const getAftersalesInfo = (data : any) => {
	return service.post("/aftersales/info", data, options);
};

// 填写寄回的快递信息
export const doAftersalesHandle = (data : any) => {
	return service.post("/aftersales/handle", data, options);
};

// 换货时的确认收货
export const doAftersalesConfirm = (data : any) => {
	return service.post("/aftersales/confirm", data, options);
};

// 获取未签署的协议
export const getSiteAgreement = (data : any) => {
	return service.post("/my/siteAgreement", data, options);
};

// 关闭订单
export const doCloseOrder = (data : any) => {
	return service.post("/order-wx/close", data, options);
};

// 再次支付订单
export const doPayAgin = (data : any) => {
	return service.post("/order-wx/pay", data, options);
};

// 查询商品信息
export const getProduct = (data : any) => {
	return service.get(`/product?leaderPhone=${data.leaderPhone}&code=${data.code}`,);
};

// 点击“我要买”时查询系统和团长手机号
export const getPhone = (data : any) => {
	return service.get("/phone", data, options);
};

// 查询当前用户作为团长的分享列表
export const getShare = (data : any) => {
	return service.get("/share", data, options);
};

// 记录团长
export const setUser = (data : any) => {
	return service.post("/user", data, options);
};

/**
 * @method 静默授权
 */
export function doAuthSilent(data : any) {
	return service.post("/common/authSilent", data);
}

/**
 * @method 授权登录
 */
export function doWxAuth(data : any) {
	return service.post("/common/auth", data);
}

// 查询分享统计
export const getShareCount = (data : any) => {
	return service.get("/share/count", data);
};